﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinQ_DTO;
namespace DAO
{
    public class PersonalizationPerUserDAO
    {
        public List<aspnet_PersonalizationPerUser> LayTatCa_PersonalizationPerUser()
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var Pers = from P in EFashionDB.aspnet_PersonalizationPerUsers
                       select P;
            return Pers.ToList();
        }

        public List<aspnet_PersonalizationPerUser> LayTatCa_PersonalizationPerUserTheoID(Guid ID)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var Pers = from P in EFashionDB.aspnet_PersonalizationPerUsers
                       where P.Id == ID
                       select P;
            return Pers.ToList();
        }

        public void XoaPersonalizationPerUserTheoID(Guid ID)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var Pers = from P in EFashionDB.aspnet_PersonalizationPerUsers
                       where P.Id == ID
                       select P;

            EFashionDB.aspnet_PersonalizationPerUsers.DeleteAllOnSubmit(Pers);
            EFashionDB.SubmitChanges();
        }



        public void ThemPersonalizationPerUser ( aspnet_PersonalizationPerUser Personal)
         {
             EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
             EFashionDB.aspnet_PersonalizationPerUsers.InsertOnSubmit(Personal);
             EFashionDB.SubmitChanges();
         }

        public void CapNhatPersonalizationPerUserTheoID(Guid ID, DateTime LastUpdate)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var Pers = from P in EFashionDB.aspnet_PersonalizationPerUsers
                       where P.Id == ID
                       select P;

            foreach (aspnet_PersonalizationPerUser appUser in Pers)
            {
                appUser.LastUpdatedDate = LastUpdate;
            }

            EFashionDB.SubmitChanges();
        }
        


    }
}
